<?php

	include("common.php");
	
	$password = md5($_POST['password']);
	$result = mysql_query("SELECT * FROM `197_teachers` WHERE `username` = '" . $_POST['username'] . "' AND `password` = '" . $password . "' AND `teacher_id` = " . $_POST['teacher_id']) or die(mysql_error());
	
	if(mysql_num_rows($result)){
		$row = mysql_fetch_assoc($result);
		$_SESSION['tusername'] = $_POST['username'];
		$_SESSION['teacher_id'] = $_POST['teacher_id'];
		include("header.php");
?>
<h1>登入</h1>
<p>登入成功，請<a href="teacherDataFind.php">按此</a>進入管理。</p>
<?php

		include("sidebar.php");
		include("footer.php");
	
	} else {
		include("header.php");
		
?>
<h1>登入</h1>
<p>登入失敗，您的帳號不存在，或您的密碼輸入錯誤，又或者您的科別不符合。</p>
<?php

		include("sidebar.php");
		include("footer.php");
		
	}
	
?>